<?php defined('SYSPATH') or die('No direct script access.');

class Model_ProductParser_Ebay extends Model_ProductParser_Abstract
{ 
    protected static $_instance = null;
    
    protected function _get_current_product_id()
    {
        $current_id = DB::select(array(DB::expr('MAX(id)'), 'max'))
            ->from('products')
            ->execute()
            ->as_array();
        $current_id = $current_id[0]['max'];
        return $current_id;
    }
    
    public function parse()
    {   
        $shop_id = 65535;
        $shop    = ORM::factory('shop', $shop_id);
        
        // Парсим хтмл как на али
        // Сортируем по дате - новые, собираем все (или 50, 100 страниц???), что выдаются, клеим дату окончания + 30 дней
        // Парсим каждый товар и актуализируем данные
        // доставка в россию??
               
        $categories = $this->_get_categoies();
        
        // TODO
        // если все элементы задания готовы, то очистить задание
        
        // Заносим все страницы категорий в задание
        foreach ($categories as $url => $category_id) {
            if ($category_id) {
                ORM::factory('parsingtask')->add_category_task($url, $shop);
            } 
        }
        
        // Цикл, пока в заданиях есть категории:
        // Добавить следующю страницу в задание
        // Добавить товары в таблицу без характеристик

        $n = 0;  
        $changed_n = 0; 
        $current_id = $this->_get_current_product_id();
        
        while (($tasks = ORM::factory('parsingtask')->get_category_tasks($shop)) && count($tasks)) {
            foreach ($tasks as $task) {
                $url  = $task->url;
                $html = self::_get_ebay_source_code($url);
                
                usleep(700000);
                
                if (!$html) {
                    continue;    
                }
                
                $next_page_url = $this->_get_next_page_url($html);
                if ($next_page_url) {
                    ORM::factory('parsingtask')->add_category_task($next_page_url, $shop);   
                } 
                
                while ($product = $this->_get_product($html)) {                        
                    $original_id        = $this->_get_product_original_id($product);
                    $url              = $this->_get_product_url($product);
                    $picture          = $this->_get_product_picture($product);
                    $name             = $this->_get_product_name($product);
                    $price            = $this->_get_product_price($product);
                    $start_date       = $this->_get_product_start_date($product);
                    $end_date         = $this->_get_product_end_date($start_date);
                    
                    $brand                = null;
                    $brand_id             = 0;
                    $original_category_id = $this->_get_original_category_id($task->url);
                    $category_id          = $this->_get_category_id($original_category_id);
                    
                    $delivery         = 1;
                    $modified_time    = time();
                    
                    $start_date       = $start_date->format('Y-m-d h:i:s'); 
                    $end_date         = $end_date->format('Y-m-d h:i:s'); 
                                        
                    try {
                        /*echo $original_id.'<br />';
                        echo $url.'<br />';
                        echo $picture.'<br />';
                        echo $name.'<br />';   
                        echo $price.'<br />';
                        echo $category_id.'<br />'; 
                        echo $original_category_id.'<br />';
                        echo $start_date.'<br />';
                        echo $end_date.'<br />'; 
                        echo '<br />';  */ 
                        
                        if ($name && $url) {
                            $current_id++;  
                            
                            DB::insert('products', array('id', 'original_id', 'brand', 'brand_id', 'category_id', 'original_category_id', 'shop_id', 'name', 'url', 
                                'picture', 'price', 'delivery', 'modified_time', 'start_date', 'end_date'))
                                    ->values(array($current_id, $original_id, $brand, $brand_id, $category_id, $original_category_id, $shop_id, $name, $url,
                                    $picture, $price, $delivery, $modified_time, $start_date, $end_date))->execute();
                            
                            DB::insert('product_data', array('product_id'))
                                    ->values(array($current_id))->execute();
                            $n++;    
                        }    
                    } catch (Database_Exception $e) {
                        if (strstr($e->getMessage(), 'Duplicate entry') !== false) {
                            $current_id--;      // возвращаем назад идентификатор, т.к. он увеличился, но запись не вставилась
                            
                            DB::update('products')
                                    ->set(array('tmp_is_available' => 1))
                                    ->where('original_id', '=', $original_id)
                                    ->where('shop_id', '=', $shop_id)
                                    ->execute();
                            
                            /*DB::update('products')
                                    ->set(array('category_id' => $category_id, 'original_category_id' => $original_category_id))
                                    ->where('original_id', '=', $original_id)
                                    ->where('shop_id', '=', $shop_id)
                                    ->execute();
                            /*DB::update('products')
                                    ->set(array('brand' => $brand, 'brand_id' => $brand_id))
                                    ->where('original_id', '=', $original_id)
                                    ->where('shop_id', '=', $shop_id)
                                    ->execute();   */
                            $changed_rows = DB::update('products')
                                    ->set(array('price' => $price))
                                    ->where('original_id', '=', $original_id)
                                    ->where('shop_id', '=', $shop_id)
                                    ->execute();
                            if ($changed_rows) {    // цена изменилась
                                $product = ORM::factory('product')
                                            ->where('original_id', '=', $original_id)
                                            ->where('shop_id', '=', $shop_id)
                                            ->find();
                                DB::delete('product_coupons')
                                    ->where('product_id', '=', $product->id)
                                    ->execute();
                                $changed_n++;   
                            }
                        } else {
                            die($e->getMessage());
                        }
                    }               
                }

                $task->mark_as_ready();
            }    
        }
        
        echo 'Changed - '.$changed_n."\n";
        return $n;   
    }
    
    protected function _get_product_original_id($html)
    {
        $source_id = $this->_cut_str(' iid="', '"', $html);
        return $source_id;
    }                
    
    protected function _get_product_url($html)
    {
        $url = $this->_cut_str('href="', '?', $html);
        //$url = str_replace(array(':', '/'), array('%3A', '%2F'), $url);
        //$url = $this->_admitad_url_prefix.$url;
        return $url;
    }
    
    protected function _get_product_picture($html)
    {
        $image = $this->_cut_str('src="', '"', $html);
        return $image;
    }
    
    protected function _get_product_name($html)
    {
        $name = $this->_cut_str('itemprop="name">', '</a>', $html);
        return $name;
    }
    
    protected function _get_product_price($html)
    {
        $price = $this->_cut_str('itemprop="price"', '<b>', $html);
        if ($price) {
            $price = '<span'.$price;
            $price = trim(strip_tags($price));        
            $price = preg_replace('/\s+/', '', $price);
        } else {
            $price = trim($this->_cut_str(' prRange">', '<b>', $html));    
            $price = preg_replace('/\s+/', '', $price);
        } 
        
        /*for ($i = 0; $i < strlen($price); $i++) {
            echo $price[$i].' - '.ord($price[$i])."\n"; 
        } 
        die(); */
        
        // костыль из-за кривого символа пробела
        $new_string = array();
        for ($i = 0; $i < strlen($price); $i++) {
            if (ord($price[$i]) != 194 && ord($price[$i]) != 160) {
                $new_string[] = $price[$i];    
            }  
        }
        $price = implode('', $new_string);
                      
        return (float)$price;
    }
    
    protected function _get_product_start_date($html)
    {
        $start_date = $this->_cut_str('class="timeLeftInfo">', '</div>', $html);
        $start_date = $this->_cut_str('class="lcol">', '</span>', $start_date);
        
        // 30.06 00:30
        $now = new DateTime();
        list($date, $time)   = explode(' ', $start_date);
        list($day, $month)   = explode('.', $date);
        list($hour, $minute) = explode(':', $time);
        
        $start_date = new DateTime();
        $start_date->setDate($now->format('Y'), $month, $day);
        $start_date->setTime($hour, $minute);
                                  
        return $start_date;  
    }
    
    protected function _get_product_end_date($start_date)
    {
        $end_date = clone $start_date;
        $end_date->add(new DateInterval('P30D'));
        
        return $end_date;  
    }
    
    protected function _get_product(&$html)
    {
        $product = $this->_cut_str('class="itemOffered">', '<div class="meta">', $html);
        return $product;    
    } 
    
    protected function _get_next_page_url($html)
    {
        $next_page = $this->_cut_str('class="pagn-next"', '</a>', $html);
        $next_page = $this->_cut_str('href="', '"', $next_page);
        return $next_page;
    } 
    
    protected function _get_original_category_id($url)
    {
        $parts = explode('/', $url);
        if (isset($parts[5])) {
            return $parts[5];   
        }
        return 0;
    }
    
    protected function _get_category_id($original_category_id)
    {
        $categories = $this->_get_categoies();
        foreach ($categories as $url => $category_id) {
            if (strstr($url, '/'.$original_category_id.'/')) {
                return $category_id;    
            }
        } 
        return 0;  
    }
    
    protected function _get_categoies()
    {  
        /*return array(
            'http://www.ebay.com/sch/Sunglasses-Fashion-Eyewear-/179239/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1864,
            //'http://www.ebay.com/sch/Leggings-/169001/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=3&_ipg=192' => 1810,
        );    */
        return array(
            // --- Одежда для малышей ---
             'http://www.ebay.com/sch/Baby-Accessories-/163222/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Baby-Shoes-/147285/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 375,
            'http://www.ebay.com/sch/Christening-/139762/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Boys-Clothing-Newborn5T-/147317/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 351,
            'http://www.ebay.com/sch/Girls-Clothing-Newborn5T-/147192/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 351,
            'http://www.ebay.com/sch/Unisex-Clothing-Newborn5T-/163397/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 351,
            'http://www.ebay.com/sch/Other-/1070/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Детская одежда, обувь и аксессуары ---
            'http://www.ebay.com/sch/Boys-Clothing-Sizes-4-Up-/11452/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 333,
            'http://www.ebay.com/sch/Boys-Shoes-/57929/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 399,
            'http://www.ebay.com/sch/Boys-Accessories-/57881/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Girls-Clothing-Sizes-4-Up-/11462/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 314,
            'http://www.ebay.com/sch/Girls-Shoes-/57974/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 380,
            'http://www.ebay.com/sch/Girls-Accessories-/15628/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Unisex-Clothing-/155198/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Unisex-Shoes-/155202/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/175640/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Театральные и карнавальные костюмы ---
            'http://www.ebay.com/sch/Costumes-/175648/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Reenactment-Theater-/175650/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Accessories-/155344/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/163149/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Фольклорная и этническая одежда ---
            'http://www.ebay.com/sch/Africa-/155241/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Asia-Pacific-Islands-/155242/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Europe-/163142/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/India-Pakistan-/155246/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Latin-America-/155252/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Middle-East-/155253/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Native-American-/163146/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/155254/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Одежда для танцев ---
            'http://www.ebay.com/sch/Adult-Dancewear-/175638/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Baby-Toddler-Dancewear-/172007/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Kids-Dancewear-/152345/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Dance-Shoes-/175639/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Аксессуары для мужчин ---
            'http://www.ebay.com/sch/Backpacks-Bags-Briefcases-/52357/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1850,
            'http://www.ebay.com/sch/Belt-Buckles-/86647/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1862,
            'http://www.ebay.com/sch/Belts-/2993/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1862,
            'http://www.ebay.com/sch/Canes-Walking-Sticks-/152537/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Collar-Tips-/177649/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Gloves-Mittens-/2994/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1863,
            'http://www.ebay.com/sch/Hairpieces-Toupees-/175626/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Handkerchiefs-/167902/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Hats-/52365/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1902,
            'http://www.ebay.com/sch/ID-Document-Holders-/169271/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1865,
            'http://www.ebay.com/sch/Key-Chains-Rings-Cases-/52373/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Money-Clips-/163583/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1865,
            'http://www.ebay.com/sch/Organizers-Day-Planners-/15665/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Scarves-/52382/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1859,
            'http://www.ebay.com/sch/Sunglasses-Fashion-Eyewear-/179239/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1864,
            'http://www.ebay.com/sch/Suspenders-Braces-/105387/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Ties-/15662/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1869,
            'http://www.ebay.com/sch/Umbrellas-/90634/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1866,
            'http://www.ebay.com/sch/Wallets-/2996/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1865,
            'http://www.ebay.com/sch/Wristbands-/106113/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1870,
            'http://www.ebay.com/sch/Mixed-Items-Lots-/175627/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/1060/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Одежда для мужчин ---
            'http://www.ebay.com/sch/Casual-Shirts-/57990/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1883,
            'http://www.ebay.com/sch/Dress-Shirts-/57991/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1883,
            'http://www.ebay.com/sch/TShirts-/15687/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1877,
            'http://www.ebay.com/sch/Athletic-Apparel-/137084/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Blazers-Sport-Coats-/3002/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1884,
            'http://www.ebay.com/sch/Coats-Jackets-/57988/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1907,
            'http://www.ebay.com/sch/Jeans-/11483/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1899,
            'http://www.ebay.com/sch/Pants-/57989/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1913,
            'http://www.ebay.com/sch/Shorts-/15689/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1873,
            'http://www.ebay.com/sch/Sleepwear-Robes-/11510/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1986,
            'http://www.ebay.com/sch/Socks-/11511/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1921,
            'http://www.ebay.com/sch/Suits-/3001/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1891,
            'http://www.ebay.com/sch/Sweaters-/11484/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1882,
            'http://www.ebay.com/sch/Sweats-Hoodies-/155183/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1881,
            'http://www.ebay.com/sch/Swimwear-/15690/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1917,
            'http://www.ebay.com/sch/Underwear-/11507/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1917,
            'http://www.ebay.com/sch/Vests-/15691/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1892,
            'http://www.ebay.com/sch/Mixed-Items-Lots-/84434/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/313/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Обувь для мужчин ---
            'http://www.ebay.com/sch/Athletic-/15709/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Boots-/11498/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1937,
            'http://www.ebay.com/sch/Casual-/24087/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Dress-Formal-/53120/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1926,
            'http://www.ebay.com/sch/Occupational-/11501/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Sandals-Flip-Flops-/11504/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1930,
            'http://www.ebay.com/sch/Slippers-/11505/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 2414,
            'http://www.ebay.com/sch/Mixed-Items-Lots-/63850/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Униформа и рабочая одежда ---
            'http://www.ebay.com/sch/Aprons-/175628/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Coveralls-Jumpsuits-/178962/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Hats-/163526/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Jackets-Vests-/175629/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Lab-Coats-/105417/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Pants-Shorts-/163525/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Scouting-Uniforms-/105418/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Scrubs-/105419/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Shirts-/175630/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/163528/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Одежда, обувь и аксессуары в стиле унисекс ---
            'http://www.ebay.com/sch/Unisex-Accessories-/155185/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Unisex-Adult-Clothing-/155192/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Unisex-Adult-Shoes-/155196/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/167905/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Свадьбы и официальные мероприятия ---
            'http://www.ebay.com/sch/Wedding-Dresses-/15720/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Bridal-Shoes-/105471/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Bridal-Accessories-/106127/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Bridesmaids-Formal-Dresses-/175633/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mother-of-the-Bride-/131474/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Womens-Formal-Hats-/131476/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mens-Formal-Occasion-/105508/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Boys-Formal-Occasion-/105520/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Girls-Formal-Occasion-/3263/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Novelty-Attire-/175632/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/1265/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Аксессуары для женщин ---
            'http://www.ebay.com/sch/Belt-Buckles-/163573/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1717,
            'http://www.ebay.com/sch/Belts-/3003/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1717,
            'http://www.ebay.com/sch/Collar-Tips-/177651/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Fascinators-Headpieces-/168998/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1724,
            'http://www.ebay.com/sch/Gloves-Mittens-/105559/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1722,
            'http://www.ebay.com/sch/Hair-Accessories-/45220/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1724,
            'http://www.ebay.com/sch/Handkerchiefs-/167906/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Hats-/45230/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1721,
            'http://www.ebay.com/sch/ID-Document-Holders-/169285/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 2362,
            'http://www.ebay.com/sch/Key-Chains-Rings-Finders-/45237/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Organizers-Day-Planners-/15735/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Scarves-Wraps-/45238/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1725,
            'http://www.ebay.com/sch/Shoe-Charms-Jibbitz-/150955/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Sunglasses-Fashion-Eyewear-/179247/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1719,
            'http://www.ebay.com/sch/Ties-/151486/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Umbrellas-/105569/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1726,
            'http://www.ebay.com/sch/Wallets-/45258/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1718,
            'http://www.ebay.com/sch/Wigs-Extensions-Supplies-/175634/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Wristbands-/106129/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1980,
            'http://www.ebay.com/sch/Mixed-Items-Lots-/15738/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/1063/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Одежда для женщин ---
            'http://www.ebay.com/sch/Athletic-Apparel-/137085/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Coats-Jackets-/63862/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1810,
            'http://www.ebay.com/sch/Dresses-/63861/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1764,
            // Чулочно-носочные изделия
                'http://www.ebay.com/sch/Leg-Warmers-/163587/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1957,
                'http://www.ebay.com/sch/Pantyhose-Tights-/11525/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1951,
                'http://www.ebay.com/sch/Socks-/163588/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1956,
                'http://www.ebay.com/sch/Stockings-ThighHighs-/11527/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1955,
            'http://www.ebay.com/sch/Intimates-Sleep-/11514/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1796,      // раскрыть
            'http://www.ebay.com/sch/Jeans-/11554/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1785,
            'http://www.ebay.com/sch/Jumpsuits-Rompers-/3009/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Leggings-/169001/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1777,
            'http://www.ebay.com/sch/Maternity-/172378/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1989,            // раскрыть
            'http://www.ebay.com/sch/Pants-/63863/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1773,
            'http://www.ebay.com/sch/Shorts-/11555/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1781,
            'http://www.ebay.com/sch/Skirts-/63864/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1753,
            'http://www.ebay.com/sch/Suits-Blazers-/63865/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1750,
            'http://www.ebay.com/sch/Sweaters-/63866/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1733,
            'http://www.ebay.com/sch/Sweats-Hoodies-/155226/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1736,
            'http://www.ebay.com/sch/Swimwear-/63867/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1823,
            'http://www.ebay.com/sch/TShirts-/63869/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1738,
            'http://www.ebay.com/sch/Tops-Blouses-/53159/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1739,
            'http://www.ebay.com/sch/Vests-/15775/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1745,
            'http://www.ebay.com/sch/Mixed-Items-Lots-/84275/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/314/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Женские сумки ---
            'http://www.ebay.com/sch/Handbags-Purses-/63852/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1707,
            'http://www.ebay.com/sch/Backpacks-Bookbags-/169292/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1711,
            'http://www.ebay.com/sch/Briefcases-Laptop-Bags-/169293/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1712,
            'http://www.ebay.com/sch/Diaper-Bags-/169295/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Travel-Shopping-Bags-/80600/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Handbag-Accessories-/163570/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mixed-Items-Lots-/169303/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Женская обувь ---
            'http://www.ebay.com/sch/Athletic-/95672/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Boots-/53557/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1842,
            'http://www.ebay.com/sch/Flats-Oxfords-/45333/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Heels-/55793/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Occupational-/53548/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Sandals-Flip-Flops-/62107/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 1831,
            'http://www.ebay.com/sch/Slippers-/11632/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mixed-Items-Lots-/63889/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Винтаж ---
            'http://www.ebay.com/sch/Vintage-Accessories-/175760/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Childrens-Vintage-Clothing-/163594/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mens-Vintage-Clothing-/175761/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mens-Vintage-Shoes-/163628/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Unisex-TShirts-/28022/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Womens-Vintage-Clothing-/175762/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Womens-Vintage-Shoes-/74976/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Vintage-Reproductions-/125472/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/91247/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            // --- Оптовые, крупные и мелкие лоты ---
            'http://www.ebay.com/sch/Boys-/45051/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Girls-/41965/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Infants-/45052/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mens-Accessories-/45053/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mens-Clothing-/50975/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mens-Shoes-/45054/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Uniforms-/50978/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Womens-Accessories-Handbags-/50980/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Womens-Clothing-/50985/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Womens-Shoes-/45056/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Mixed-Lots-/45057/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
            'http://www.ebay.com/sch/Other-/14879/i.html?LH_BIN=1&LH_ItemCondition=1000&_udlo=&_udhi=&_sop=10&_ipg=192' => 0,
        );
    }          
}
